(function($) {
	
	$.controller.photo = {
			owner: null,
			title: "",
			visits: 0,
			id: null,
			index: function(actionVars) {
				
			},
			load: function (actionVars) {
				this.loadPhoto(actionVars);
			},
			loadPhoto: function (actionVars) {
				var controller = this;
				$.getJSON("core/photo/get/id/"+actionVars.id,function(data){
					if(data.error)
					{
						jAlert("Error while loading photo '"+actionVars.id+"': "+data.message,"Error");
						location.href="#album";
					}else{
						controller.owner = data.owner;
						controller.visits = data.visits;
						controller.title = data.title;
						controller.id = actionVars.id;
						
						$.widget.photo.load(actionVars.id);
						$.widget.photoComments.load(actionVars.id);
						$.widget.photoOptions.load(data.owner);
					}
				});
			}
	}
	
})(jQuery);